
let timer = null
import { getNum } from '../../utils/util'

let urlPromise = null

Page({

  data: {
    animated2: '',
    animated1: '',
    xsI: 1,
    xsaa: 1,
    img: '../../imgs/sl.png',
    global_top: '28px',
    current: "",
    isFirst: true,
    processing: false,
    act: 0,
    list: [
      "吃土",
      "多少斤了你心里没数吗",
      "看看兜里有多少钱",
      "我说吃啥你也不会吃",
      "小浣熊干脆面",
      "西北风",
      "最便宜的",
      "🐂🥩",
      "💣🐔",
      "🍡",
      "去吃米其林..",
      "修仙",
      "明天再吃",
      "蹭饭",
      "鲱🐟罐头",
      "吃啥啊，健身去",
      "饿一天",
      "别吃小面条",
      "海鲜大餐",
      "吃狗粮",
      "奥利..奥",
      "吃..个教训",
      "🥗沙拉",
      "酸菜鱼",
      "老八秘制小🍔",
      "披萨",
      "哪家贵吃哪家"
    ],
    xs: [
      '赶高铁，点了一份外卖，结果一直没到，我跟商家说取消吧，我高铁时间到了，商家：我通知下骑手，做好追高铁的准备...',
      '在e了么点了份外卖，半个小时过去了还没送到，我发消息给骑手问什么原因？ 骑手：雨太大，送不了，推荐您点隔壁美团... 我：美团能送？ 骑手：对呀，他们要钱不要命的...',
      '我：麻烦帮我带罐可乐。 骑手：好的，带几瓶？ 我：带两瓶，一瓶给你。 骑手：好的，那我要1.5L的...',
      '出差到重庆，点了份外卖，结果外卖小哥就在我发他的位置周边画圈圈，我一个电话过去问他什么意思？小哥说他迷路了...',
      '电话给外面小哥，我：你怎么回事呀？ 骑手：在你小区楼下被一条狗拦住了，我一动它就咬。 我：我不信，你动一下试试？ 骑手：好，你听着哈，汪汪汪...汪汪汪...',
      '今天参加了个电动车竞速比赛，毫无意外的拿了冠军，颁奖的时候主持人问我技术在哪练的？ 我：都是自学成才，因为我是送外卖的...',
      '有一小哥点了一份不麻不辣的麻辣烫，外卖小哥送的有点儿迟了，在门口拿着单子说.不好意思啊，你要的不麻不辣的麻辣烫现在也不烫了。',
      '这年头，能在宿舍，公司楼下默默等着你，给你送上温热的早饭午饭晚饭，不管严寒酷暑刮风下雨总会很耐心的男人——只会是送外卖的。',
      '一天中午我们寝室大哥打电话叫了份外卖，隔了很久了还没送来。于是就又打过去想催催，结果发现自己手机竟然停机了。在大哥到处找人交话费的时候，他电话响了，是那个送外卖的！是的，送外卖的为了找到他，给他交了10块话费……',
      '最近学校查得严，不让外卖进宿舍。那天下着雨，我看见一个外卖小哥可怜兮兮地躲在树底下给同学打电话：“救命啊，有人在抓我，你们的外卖怎么办呀？',
      '我有个室友，自以为很能吃辣。在外卖单上备注“只要辣不死，就往死里辣”，这么嚣张的言论严重挑衅了老板的自尊。直接给加了半碗的辣椒，于是当晚这位旁友就在卫生间里，好好反思了自己的所作所为。',
      '',
    ],
    //外卖数据字段
    miniData: [
      //饿了么1对应饿了么红包
      {
        "appId": "wxece3a9a4c82f58c9",
        
        "path": "taoke/pages/shopping-guide/index?scene=tdbKqmu"
        //这里改成你的链接
      },
      //美团1
      {
        "appId": "wxde8ac0a21135c07d",
        //这里改成你的链接
        "path": "/index/pages/h5/h5?lch=cps:waimai:5:a144a9fa40a42c55af00214bb4bb3993971:14284dingdanxiameituanwaimai:2:70690&f_userId=1&weburl=https%3A%2F%2Fclick.meituan.com%2Ft%3Ft%3D1%26c%3D1%26p%3DOWMpZ-uzIFOVe6JyOONs3dXuqV0qcAf-r-KCvHdXiNfM3oMXlDSgQ1lHQ7sc1bHIMXeq2XWRYP9S3VMvpbQU5suS6wIbvlY8ysKwoMucfvM_jifUX790iimowFdBzJu-hndx2fPCEhbtnHh2ZbYXOlbRGAfU2FrBss1VXKKkZrQwquo7AS5IPdkvFIBudqMPodQm82bIPcT8C83f6zr1KGEnYMAnpbcdfhgbU7I1sSGBlrgYSmeI5tTUZPrw6fLsCqAIKtr9jcbE4hIBqj164GXpa9AZArdnBj6nIeMgXHoaS_hymiCzASEqYoUpXg3Ndf4SRvr_v60nnPm_4JCAHFzHfjougXjgWE4DFXbrqIoZaWV5c9oEMoJh4Ytpb7aJdH-IZahxyarZd9bScJnhkdWolsNma9xYCn-m_drBXsZGRxvzcga9s5tCecjwb_pqUBFwy4bneTJrHIrZn9lWRbblCq17EOPm3zP_svDtwmCR5ukPHOuO2XUR6KHe-z2UxtKtNgABUoosT2UQSzUJsVPIzRbNep_sGTjqvnatwaNRouigfPfyUJKUP5aWs-cW29dcIMdjVIYq-P60EvRvllF-6tGr2L8vKy129L54yCiK4Ir05HBjhxLR4Qnh9crRwaVNxTHuSVPEFiVfAjTX6Zv4ndltT7rgl9UeOX8UXtnoRC7gZU3lQvVyy0J-ZVK1m8cuQGj5iFbgUu5tyU6IWg2pihO361hgcxLWyAXCxzQO7Awi6JxwfIWYDuTc44pvNzU0HTzPH42327sXiGSjwg&f_token=1"
      },
      //饿了么2对应左下
      {
        "appId": "wxece3a9a4c82f58c9",
        "path": "ele-recommend-price/pages/guest/index?inviterId=e8da0142c7&chInfo=ch_wechat_chsub_CopyLink&_ltracker_f=tjyj1_wx_banner3"
        //这里改成你的链接
      },
      //对应美团优选
      {
        "appId": "wx77af438b3505c00e",
        //这里改成你的链接
        "path": "subPackages/webview/index?lch=cps:mix:5:a144a9fa40a42c55af00214bb4bb3993971:14284dingdanxiameituanyouxuan:22:70690&url=https%3A%2F%2Frunion.meituan.com%2Fyouxuan%2Furl%3Fkey%3Da144a9fa40a42c55af00214bb4bb3993971%26sid%3D14284dingdanxiameituanyouxuan%26target%3Dhttps%253A%252F%252Fi.meituan.com%252Fawp%252Fhfe%252Fblock%252F0fa89e3742cb33896d37%252F116372%252Findex.html%253FtargetPath%253D%25252FsubPackages%25252Ftransfer%25252Findex%25253Fprotocol%25253Digrocery%2525253A%2525252F%2525252Fwww.grocery.com%2525252Fmain%2525253Futm_term%2525253D%2525257B%25252522mtlm%25252522%2525253A%25252522cps%2525253Amix%2525253A5%2525253Aa144a9fa40a42c55af00214bb4bb3993971%2525253A14284dingdanxiameituanyouxuan%2525253A22%2525253A70690%25252522%2525257D%2526appkey%253Da144a9fa40a42c55af00214bb4bb3993971%253A14284dingdanxiameituanyouxuan"
      },
      //饿了么生鲜对应生鲜
      {
        "appId": "wxece3a9a4c82f58c9",
        //这里改成你的链接
        "path": "pages/sharePid/web/index?scene=https://s.click.ele.me/mPITomu"
      },
      //美团果蔬对应美团生鲜
      {
        "appId": "wxde8ac0a21135c07d",
        //这里改成你的链接
        "path": "/index/pages/h5/h5?lch=cps:waimai:5:a144a9fa40a42c55af00214bb4bb3993971:14284dingdanxiameituanshangou:4:70690&f_userId=1&weburl=https%3A%2F%2Fclick.meituan.com%2Ft%3Ft%3D1%26c%3D1%26p%3DOWMpZ-uzIFOVe6JyOONs3cgFtCGIpBffprPipc5RY4weWgO1Lyt_UvwcB0Swox5ulcg6NfzT69VPd01Zxy5Nnpuh_CVBT9sYw0-ts3lE17ObKofEluyjWPFZEK1Jt2kt4kYJCiZRNzwTwFu4aDKSgs0X75BPpoAFZ59pNyIBjBHmGeJ4Qk71Zq-RY_qKH-TJI1cxO5j2Jp7vNQiFXGHC_X0yvlLM35VL7HTZp4p7gmtCUpNhMAjHAN2CWwFfEg4osAbj0NWAhaW5OU3k7VIS_23C1qAA3aQ2BJbGOcZh5ROymrOm0XQKR_wu6xjiUyKN2Xt-Jkp0Y-rTyjrEg1aPiPKPoxU77br20fq5K1zPiyxIipK0cuxxa46yLB8qEpc1740CHJetoOBMCZqcqO1_OT1tnucBcu1qZWmL0PeQg5DIETSMEaul-M1j8pODRbGaZ1ymFkyZyiw4eoOXh9j2U397_Kxc9eWnsdjrxiYetQRLYdzdnV1KN3pVjqrNDb876fKez__KUpTpGnN9tcn4DM8cYWOgyViKi_seDdPVRSEFnaOnpQAwACd6FpYPsMfY68yod9_qhBiJi7KhQhZ-fbNNG1k3htZfZeS0HbnZcj4wi_9IFqOZU6DlEOloGzxfN5bU0Tj8sep8FwUDjcSM2Pm7oMW1dJww-Tk04-c8vyKYqZty537kost9cThBxahUOu85kaCjNq7mb54zsn1Sl_6429Rq-pFY3jsajcJLvAv3_p7Xc0vJ1JMbhITigK5VM6AA2Pbd5LZnIJLckwwusMOGXpfeT76lSPM9_IU5XYQMOsgsv4F9DciNQ0tidDzF&f_token=1"
      }
    ]
  },
  onShareAppMessage(res) {
    var messages = [{
      title: '这样点外卖，一年省下好多钱',
      path: '/pages/index/index'
    }, {
      title: '点外卖前先领券，吃霸王餐',
      path: '/pages/index/index'
    }, {
      title: '震惊！小伙点外卖竟然花了1分钱',
      path: '/pages/index/index'
    }, {
      title: '从这点外卖，你也可以吃霸王餐',
      path: '/pages/index/index'
    }];
    let data = messages[Math.floor(Math.random() * messages.length)]
    data.imageUrl = "/cp/fx.png"
    return data;
  },

  onShareTimeline: function (res) {
    var messages = [{
      title: '这样点外卖，一年省下好多钱',
      path: '/pages/index/index'
    }, {
      title: '点外卖前先领券，吃霸王餐',
      path: '/pages/index/index'
    }, {
      title: '点外卖不用优惠券，你就out了',
      path: '/pages/index/index'
    },  {
      title: '震惊！小伙点外卖竟然花了1分钱',
      path: '/pages/index/index'
    }, {
      title: '从这点外卖，你也可以吃霸王餐',
      path: '/pages/index/index'
    }];
    let data = messages[Math.floor(Math.random() * messages.length)]
    data.imageUrl = "/cp/fx.png"
    return data;
  },


  touchStart: function (e) {
    var startX1 = e.changedTouches[0].x
    var startY1 = e.changedTouches[0].y
    ctx.save();  //保存当前坐标轴的缩放、旋转、平移信息
    ctx.beginPath() //开始一个路径 
    ctx.clearRect(startX1, startY1, 10, 10);
    ctx.restore();  //恢复之前保存过的坐标轴的缩放、旋转、平移信息
  },
  // 事件处理函数
  bindViewTap() {
    wx.navigateTo({
    })
  },
  morexh() {
    let i = getNum(0, this.data.xs.length - 1)
    this.setData({
      xsI: i,
    })
  },
  onLoad() {
    let that = this
  
    let i = 0
    setInterval(() => {
      i++
      if (i % 4 == 0) {
        this.setData({
          animated2: 'swing',
          animated1: ''
        })
      }
      else if (i % 4 == 2) {
        this.setData({
          animated2: '',
          animated1: 'swing'
        })
      }
      else {
        this.setData({
          animated2: '',
          animated1: ''
        })
      }
    }, 1200)

    this.setData({
      xsI: getNum(0, this.data.xs.length - 1, this)
    })
    wx.getSystemInfo({
      success: (res) => {
        console.log(res.platform)
        console.log(res.statusBarHeight)
        let nav_top = res.statusBarHeight + 4
        if (res.platform.toLowerCase() == 'android') {
          nav_top += 4
        }

        this.setData({
          global_top: nav_top + 20 + 'px',
        })
      },
    })
  },
  onRandom() {
    if (timer) {
      clearInterval(timer)
      timer = null
      this.setData({
        processing: false
      })
      return
    } else {
      timer = setInterval(() => {
        this.setData({
          current: this.data.list[getNum(0, this.data.list.length - 1)]
        })
      }, 100)
      this.setData({
        processing: true,
        isFirst: false
      })
    }
  },
  goact0() {
    this.setData({ act: 0 })
  },
  goact1() {
    this.setData({ act: 1 })
  },
  wm1() {

    wx.navigateToMiniProgram(
      this.data.miniData[0]
    )
  },
  wm2() {
      wx.navigateToMiniProgram(
        this.data.miniData[1]
      )

  },
  wm3() {
      wx.navigateToMiniProgram(
        this.data.miniData[2]
      )

  },
  wm4() {
      wx.navigateToMiniProgram(
        this.data.miniData[3]
      )

  },
  wm5() {
      wx.navigateToMiniProgram(
        this.data.miniData[4]
      )

  },
  goxr() {
    wx.navigateTo({
      url: '/pages/makee/makee'
    })
  },
  wm6() {
      wx.navigateToMiniProgram(
        this.data.miniData[5]
      )

  },
})